package fudan.se.project.service.infrastructure.entity.conference;


import fudan.se.project.domain.conference.Topic;
import fudan.se.project.repository.entity.conference.TopicRepository;
import fudan.se.project.service.infrastructure.base.IEntityService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
public class TopicService implements IEntityService<Topic> {

    private final TopicRepository topicRepository;

    public TopicService(TopicRepository topicRepository) {
        this.topicRepository = topicRepository;
    }

    @Override
    public Topic save(Topic topic) {
        return topicRepository.save(topic);
    }

    @Override
    public Iterable<Topic> saveAll(Collection<Topic> topics) {
        return topicRepository.saveAll(topics);
    }

    @Override
    public Topic findById(long id) {
        return topicRepository.findById(id);
    }

    public List<Topic> findByConferenceId(long id) {
        return topicRepository.findTopicsByConferenceId(id);
    }


}
